package com.lsc.manage.menu.controller;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Map;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import com.lsc.manage.menu.dto.MenuDTO;
import com.smf.lsc.core.respones.Result;
import com.smf.lsc.core.respones.ResultUtil;

import lombok.extern.slf4j.Slf4j;

@RestController
@Slf4j
@Validated
@RequestMapping("/manage/menu")
public class MenuController {

	@GetMapping("/getCurrentMenu")
	public Result<List<MenuDTO>> getCurrentMenu()
	{
		List<MenuDTO> list=null;
		try {
		String s = "";
        InputStreamReader in = new InputStreamReader(new FileInputStream(new File("F:\\menu.txt")),"UTF-8");
        BufferedReader br = new BufferedReader(in);
        StringBuffer content = new StringBuffer();
        while ((s=br.readLine())!=null){
            content = content.append(s);
        }
        String ss= content.toString();
        Map map = (Map)JSON.parse(ss); 
        list=(List<MenuDTO>)JSON.parse(map.get("data").toString());
		} catch (IOException e) {
            e.printStackTrace();
        }
		return ResultUtil.successResult(list,"");
	}
}
